import { observable, action } from 'mobx';
import { WeaTableNew } from 'comsMobx';

const { TableStore } = WeaTableNew;
import { WeaTools } from 'ecCom';


import ListBaseStore from './ListBaseStore';
import Apis from '../apis/car';
import { WeaLocaleProvider } from 'ecCom';

const getLabel = WeaLocaleProvider.getLabel;
/**
 * 车辆查询Store
 */
export default class CarSearchStore extends ListBaseStore {
  constructor() {
    super();
    this.selectedKey = 'all';
  }


	// 加载列表数据
	@action doTableLoading = (params) => {
	  this.showLoading(true);
	  let resultParams = this.getFormParams();
	  resultParams = { ...resultParams, ...params };
	  Apis.getCarSearchList(resultParams).then(
	    (result) => {
	      const sessionkey = result.sessionkey;
	      this.sessionkey = sessionkey;
	      this.tableStore.getDatas(sessionkey, 1);
	      this.showLoading(false);
	    },
	  );
	}

	// 初始化车辆查询页面查询条件
	@action initConditionDatas = (params) => {
	  Apis.getCarSearchListCondition(params).then(
	    (result) => {
	      const { conditioninfo } = result;
	      this.conditioninfo = conditioninfo;
	      this.initFormFields(conditioninfo); // 一定要先初始化initFormFields表单对象
	    },
	  );
	}
}
